<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Specify a function to capture and/or process output from a runkit sandbox</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.runkit-sandbox-output-handler" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">runkit_sandbox_output_handler</h1>
  <p class="verinfo">(PECL runkit &gt;= 0.7.0)</p><p class="refpurpose"><span class="refname">runkit_sandbox_output_handler</span> &mdash; <span class="dc-title">
   Specify a function to capture and/or process output from a runkit sandbox
  </span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.runkit-sandbox-output-handler-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>runkit_sandbox_output_handler</strong></span>
    ( <span class="methodparam"><span class="type">object</span> <code class="parameter">$sandbox</code></span>
   [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$callback</code></span>
  ] ) : <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span></div>

  <p class="para rdfs-comment">
   Ordinarily, anything output (such as with <span class="function"><a href="echo.html" class="function">echo</a></span>
   or <span class="function"><a href="print.html" class="function">print</a></span>) will be output as though it were printed
   from the parent&#039;s scope.  Using <span class="function"><strong>runkit_sandbox_output_handler()</strong></span>
   however, output generated by the sandbox (including errors), can be captured
   by a function outside of the sandbox.
  </p>

  <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">沙箱支持（是 <span class="function"><a href="runkit_lint.html" class="function">runkit_lint()</a></span>，<span class="function"><a href="runkit_lint_file.html" class="function">runkit_lint_file()</a></span>
函数，与 <strong class="classname">Runkit_Sandbox</strong> 类所必需）仅可用于
PHP 5.1.0 或 PHP 5.0 的特别修补版本，并需启用线程安全。更多信息可参见 runkit 包中的
<var class="filename">README</var> 文件。</span></p></blockquote>

  <blockquote class="note"><p><strong class="note">Note</strong>: 
    <strong>Deprecated</strong><br />
    <p class="para">
      As of runkit version 0.5, this function is deprecated and is scheduled to
      be removed from the package prior to a 1.0 release.  The output handler for
      a given Runkit_Sandbox instance may be read/set using the array offset syntax
      shown on the <a href="runkit.sandbox.html" class="link">Runkit_Sandbox</a> class definition page.
    </p>
  </p></blockquote>

 </div>


 <div class="refsect1 parameters" id="refsect1-function.runkit-sandbox-output-handler-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">sandbox</code></dt>

     <dd>

      <p class="para">
       Object instance of Runkit_Sandbox class on which to set output handling.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">callback</code></dt>

     <dd>

      <p class="para">
       Name of a function which expects one parameter.
       Output generated by <code class="parameter">sandbox</code> will be passed
       to this callback.  Anything returned by the callback will be displayed
       normally.  If this parameter is not passed then output handling will not be changed.
       If a non-truth value is passed, output handling will be disabled and will revert to
       direct display.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.runkit-sandbox-output-handler-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns the name of the previously defined output handler callback, or
   <strong><code>FALSE</code></strong> if no handler was previously defined.
  </p>
 </div>


 
 <div class="refsect1 examples" id="refsect1-function.runkit-sandbox-output-handler-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-559">
    <p><strong>Example #1 Feeding output to a variable</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">capture_output</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$GLOBALS</span><span style="color: #007700">[</span><span style="color: #DD0000">'sandbox_output'</span><span style="color: #007700">]&nbsp;.=&nbsp;</span><span style="color: #0000BB">$str</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;return&nbsp;</span><span style="color: #DD0000">''</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">$sandbox_output&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">''</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$php&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Runkit_Sandbox</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">runkit_sandbox_output_handler</span><span style="color: #007700">(</span><span style="color: #0000BB">$php</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'capture_output'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$php</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">echo</span><span style="color: #007700">(</span><span style="color: #DD0000">"Hello\n"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$php</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">eval</span><span style="color: #007700">(</span><span style="color: #DD0000">'var_dump("Excuse&nbsp;me");'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$php</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">die</span><span style="color: #007700">(</span><span style="color: #DD0000">"I&nbsp;lost&nbsp;myself."</span><span style="color: #007700">);<br />unset(</span><span style="color: #0000BB">$php</span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #DD0000">"Sandbox&nbsp;Complete\n\n"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #0000BB">$sandbox_output</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Sandbox Complete

Hello
string(9) &quot;Excuse me&quot;
I lost myself.
</pre></div>
    </div>
   </div>
  </p>
 </div>



</div></div></div></body></html>